// JavaScript Document
var currentPage;//页数
var row;//table总行数
var allPage;//所有页数
var pageSet;//设置每行显示
function pageTest(){
	jQ(function(){
		var tb=jQ("#test tbody tr:has(td)");
		row=tb.length;
		pageSet=6;
		/*
			当总行数大于设置每行显示时开启翻页功能否则不启用翻页功能
		*/
		if(row>pageSet){
			jQ("#pageIt").show();
			tb.hide();
			currentPage=1;
			allPage=parseInt(""+((row+pageSet-1)/pageSet),10);
			jQ('#prePage').css({"background-position":"-24px 0px"});
			jQ('#nexPage').css({"background-position":"0px 0px"});
			jQ('#firstPage').css({"background-position":"-24px 0px"});
			jQ('#lastPage').css({"background-position":"0px 0px"});
			showRow(currentPage,tb);
		}else{
			jQ("#pageIt").hide();
		}
	});
}
/*
显示TD
*/
function showRow(page,table){
	currentPage=page-0;
	table.hide();		
	var first=(currentPage-1)*pageSet; //alert(first);
	var last=pageSet*currentPage; //alert(last);
	if(last>row){
		last=row;
	}
	for(var i=first;i<last;i++){
		table.eq(i).show();
	}

}
/*
显示上页
	background: url(../../image/detailPointview/tab.png); 
	background-position: 59px 0px;
	jQ("#"+id).parent().css({"background-position":"0px 0px"});	
*/
function showPre(){
	jQ(function(jQ){
		var tb=jQ("#test tbody tr:has(td)");
		var p;
		jQ('#lastPage').css({"background-position":"0px 0px"});
		if(currentPage-0==1){
			p=1;
		}
		else {
			p=currentPage-1;
			jQ('#nexPage').css({"background-position":"0px 0px"});
		}
		if(p==1){
			jQ('#prePage').css({"background-position":"-24px 0px"});
			jQ('#firstPage').css({"background-position":"-24px 0px"});
		}
		showRow(p,tb);
	});
}
/*
显示下页
*/
function showNext(){
	jQ(function(jQ){
		var tb=jQ("#test tbody tr:has(td)");
		var p;
		jQ('#firstPage').css({"background-position":"0px 0px"});
		if(currentPage==allPage){
			p=currentPage;
		}
		else {
			p=currentPage+1;
			jQ('#prePage').css({"background-position":"0px 0px"});
			if(p==allPage){
				jQ('#nexPage').css({"background-position":"-24px 0px"});
				jQ('#lastPage').css({"background-position":"-24px 0px"});
			}
		}
		showRow(p,tb);
	});
}
/*
前页，尾页跳转
*/
function jumpPage(obj){
	jQ(function(jQ){
		var id=obj.id;//alert(id);
		var temp1="firstPage";
		var temp2="lastPage";
		var tb=jQ("#test tbody tr:has(td)");
		var p;
		if(id==temp1){
			p=1;
			jQ('#prePage').css({"background-position":"-24px 0px"});
			jQ('#nexPage').css({"background-position":"0px 0px"});
			jQ('#firstPage').css({"background-position":"-24px 0px"});
			jQ('#lastPage').css({"background-position":"0px 0px"});
			showRow(p,tb);
		}
		if(id==temp2){
			p=allPage;
			jQ('#prePage').css({"background-position":"0px 0px"});
			jQ('#nexPage').css({"background-position":"-24px 0px"});
			jQ('#lastPage').css({"background-position":"-24px 0px"});
			jQ('#firstPage').css({"background-position":"0px 0px"});
			showRow(p,tb);
		}
	});
}